﻿using System.ComponentModel.Composition;
using Polenter.Mcm;

namespace McmWinFormsApplication1.Components
{
    /// <summary>
    ///     A component can manage its state, it can access other components using its Components property
    /// </summary>
    [Export(typeof (McmComponent))]
    public class CurrentOutputTextComponent : McmComponent
    {
        private string _currentOutputText;

        public string CurrentOutputText
        {
            get { return _currentOutputText; }
            private set
            {
                _currentOutputText = value;
                Components.Messages.Post(new CurrentOutputTextChangedMessage());
            }
        }

        [MessageSubscriber(McmComponentContainer.MessagesChannelName)]
        private void handleReverseTextResponseMessage(ReverseTextResponseMessage m)
        {
            if (m.HasError)
            {
                return;
            }
            CurrentOutputText = m.OutputText;
        }
    }
}